package org.popupcommunication.model;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

@Entity
@Table(name = "reponses_sujets_forum")
public class ResponseForum implements Serializable {

	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int idReponse;	
	
	@ManyToOne
	private User postedBy;	
	
	@ManyToOne
	private SujetForum sujet;	
	
	@NotNull
	@Column(nullable = false, columnDefinition = "TEXT")
	private String contenu;
	
	private Date dateLastModification;
	private Date dateModification;
	private Date dateModeration;
	
	ResponseForum(){}
	public ResponseForum(User u, SujetForum s){
		this.postedBy=u;
		this.sujet=s;
	}
	public int getIdReponse() {
		return idReponse;
	}

	public void setIdReponse(int idReponse) {
		this.idReponse = idReponse;
	}

	public User getPostedBy() {
		return postedBy;
	}

	public void setPostedBy(User postedBy) {
		this.postedBy = postedBy;
	}

	public SujetForum getSujet() {
		return sujet;
	}

	public void setSujet(SujetForum sujet) {
		this.sujet = sujet;
	}

	public String getContenu() {
		return contenu;
	}

	public void setContenu(String contenu) {
		this.contenu = contenu;
	}

	public Date getDateLastModification() {
		return dateLastModification;
	}

	public void setDateLastModification(Date dateLastModification) {
		this.dateLastModification = dateLastModification;
	}	
	public void addTagEditReponse(){
		this.dateModification = new Date();
	}
	public void addTagModereReponse(){
		this.dateModeration = new Date();
	}

	@Override
	public String toString() {
		return "ResponseForum [idReponse=" + idReponse + ", postedBy="
				+ postedBy + ", sujet=" + sujet + ", contenu=" + contenu
				+ ", dateLastModification=" + dateLastModification + "]";
	}
	public Date getDateModification() {
		return dateModification;
	}
	public void setDateModification(Date dateModification) {
		this.dateModification = dateModification;
	}
	public Date getDateModeration() {
		return dateModeration;
	}
	public void setDateModeration(Date dateModeration) {
		this.dateModeration = dateModeration;
	}
	
}
